using System.Security.Cryptography;
using System.Text;
using Twins.Interface;

namespace Twins.Classes
{
    public class Md5CodeOperation : ICodeOperation
    {
        public string Execute(string lineCode)
        {
            MD5 md5Hasher = MD5.Create();
            byte[] hash = md5Hasher.ComputeHash(Encoding.Unicode.GetBytes(lineCode));
            var stringBuilder = new StringBuilder();
            for (int i = 0; i < hash.Length; i++)
            {
                stringBuilder.Append(hash[i].ToString("x2"));
            }
            return stringBuilder.ToString();
        }
    }
}